package _28define.tcp;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server2 {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket=new ServerSocket(8888);
        Socket socket=serverSocket.accept();
        InputStream in=socket.getInputStream();
        int readcount;
        byte[] bytes=new byte[1024];
        while ((readcount=in.read(bytes))!=-1){
            //out.write(bytes,0,readcount);
            System.out.println(new String(bytes,0,readcount));
        }
        OutputStream outputStream=socket.getOutputStream();
        outputStream.write("File upload success!".getBytes());
        socket.close();
        serverSocket.close();
    }
}
